<template>
  <div class="EMPIAdministration_XSSJ">
    <div class="pubBig Privilege">
      <div class="h0">
        <p class="lt"></p>
      </div>
      <div class="dDownMain">
        <div
          class="twoBox"
          :style="this.$route.query.Token ? 'top:50px;left:10px' : 'top: 100px'"
        >
          <el-row>
            <el-col :span="24">
              <div style="padding: 10px">
                <span>主索引：</span>
                <el-input
                  v-model="code"
                  style="width: 15%"
                  size="small"
                ></el-input>
                <el-button
                  icon="el-icon-search"
                  size="small"
                  style="margin-left: 10px"
                  @click="(page_right_b.page = 1), getTableData_right_b()"
                ></el-button>
              </div>
              <el-table
                :data="tableData_right_b"
                style="width: 100%"
                :row-key="getRowKeys_right_b"
                :expand-row-keys="expands_right_b"
                @expand-change="expandSelect_right_b"
                v-loading="right_table_loading"
                height="600"
              >
                <el-table-column type="expand">
                  <template slot-scope="props">
                    <!-- <el-tabs
                      v-model="activeName_right_b"
                      type="card"
                      style="width: 90%; margin-left: 10px"
                    >
                      <el-tab-pane label="服务对象" name="first">
                        <el-form
                          label-position="left"
                          inline
                          class="demo-table-expand"
                          label-width="130px"
                        >
                          <el-form-item label="生效日期">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.CreateDate"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="失效日期">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.EffDate"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="机构名称">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.Organization"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="姓名">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.Name"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                        </el-form>
                      </el-tab-pane>
                      <el-tab-pane label="个体生物学" name="second">
                        <el-form
                          label-position="left"
                          inline
                          class="demo-table-expand"
                          label-width="130px"
                        >
                        </el-form>
                      </el-tab-pane>
                      <el-tab-pane label="个体危险性" name="third">
                        <el-form
                          label-position="left"
                          inline
                          class="demo-table-expand"
                          label-width="130px"
                        >
                          <el-form-item label="个体危险性名称">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.Risk"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="个体危险性代码">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.RiskCode"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                        </el-form>
                      </el-tab-pane>
                      <el-tab-pane label="人口学" name="fourth">
                        <el-form
                          label-position="left"
                          inline
                          class="demo-table-expand"
                          label-width="130px"
                        >
                          <el-form-item label="年龄">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.Age"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="职业编码系统名称" v-if="false">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.Professional"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="出生日期">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.Born"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="出生地">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.BornAddress"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                        </el-form>
                      </el-tab-pane>
                      <el-tab-pane label="联系人" name="fifth">
                        <el-form
                          label-position="left"
                          inline
                          class="demo-table-expand"
                          label-width="130px"
                        >
                          <el-form-item label="号码">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.ContactIdCard"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="生效日期">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.ContactCreateDate"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="失效日期">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.ContactEffDate"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="机构名称">
                            <el-input
                              size="mini"
                              v-model="
                                props.row.PatientInfo.ContactOrganization
                              "
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="联系人-姓名">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.ContactName"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                        </el-form>
                      </el-tab-pane>
                      <el-tab-pane label="地址" name="sixth">
                        <el-form
                          label-position="left"
                          inline
                          class="demo-table-expand"
                          label-width="130px"
                        >
                          <el-form-item label="工作单位名称">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.Company"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="地址-省">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.Province"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="地址-市">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.City"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="地址-县">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.Area"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="地址-乡">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.Countryside"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="地址-村">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.Village"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="地址-门牌号码">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.HouseNumber"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="邮政编码">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.ZipCode"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="行政区划代码">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.DivisionCode"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                        </el-form>
                      </el-tab-pane>
                      <el-tab-pane label="通信" name="seventh">
                        <el-form
                          label-position="left"
                          inline
                          class="demo-table-expand"
                          label-width="130px"
                        >
                          <el-form-item label="类别" v-if="false">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.TelCategory"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="号码">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.Telphone"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="电子邮件地址">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.Email"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                        </el-form>
                      </el-tab-pane>
                      <el-tab-pane label="医保" name="eighth">
                        <el-form
                          label-position="left"
                          inline
                          class="demo-table-expand"
                          label-width="130px"
                        >
                          <el-form-item label="类别" v-if="false">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.Medical"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                        </el-form>
                      </el-tab-pane>
                      <el-tab-pane label="卫生服务机构" name="ninth">
                        <el-form
                          label-position="left"
                          inline
                          class="demo-table-expand"
                          label-width="130px"
                        >
                          <el-form-item label="机构名称">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.MedicOrganization"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="机构组织代码">
                            <el-input
                              size="mini"
                              v-model="
                                props.row.PatientInfo.MedicOrganizationCode
                              "
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="机构负责人">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.MedicLegal"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="机构地址">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.MedicAddress"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="科室名称">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.MedicDepart"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="机构角色">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.MedicOrgRole"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="机构角色代码">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.MedicOrgRoleCode"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                        </el-form>
                      </el-tab-pane>
                      <el-tab-pane label="卫生服务者" name="tenth">
                        <el-form
                          label-position="left"
                          inline
                          class="demo-table-expand"
                          label-width="150px"
                        >
                          <el-form-item label="服务者平台编码">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.MedicCode"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="服务者姓名">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.MedicName"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="服务者职责">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.MedicRole"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="服务者职责代码">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.MedicRoleCode"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="服务者医师资格标志">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.MedicDoctorCert"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="服务者学历">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.MedicEducation"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="服务者所学专业">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.MedicMajor"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="服务者专业技术职称">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.MedicProfessional"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                          <el-form-item label="服务者职务">
                            <el-input
                              size="mini"
                              v-model="props.row.PatientInfo.MedicJob"
                              :disabled="true"
                            >
                            </el-input>
                          </el-form-item>
                        </el-form>
                      </el-tab-pane>
                    </el-tabs> -->
                    <table
                      border="1"
                      style="width: 100%"
                      class="table_style"
                      cellspacing="0"
                    >
                      <tr>
                        <th>相似患者主索引</th>
                        <th>类别代码</th>
                        <th>号码</th>
                        <th>姓名</th>
                        <th>性别代码</th>
                        <th>年龄</th>
                        <th>出生日期</th>
                        <th>出生地</th>
                        <th>联系电话</th>
                      </tr>
                      <tr>
                        <td>
                          {{ props.row.RepeatPatientInfo.Code }}
                        </td>
                        <td>
                          {{ props.row.RepeatPatientInfo.Category }}
                        </td>
                        <td>
                          {{ props.row.RepeatPatientInfo.IdCard }}
                        </td>
                        <td>
                          {{ props.row.RepeatPatientInfo.Name }}
                        </td>
                        <td>
                          {{
                            props.row.RepeatPatientInfo.Gender == 1
                              ? "男"
                              : props.row.RepeatPatientInfo.Gender == 2
                              ? "女"
                              : "未知"
                          }}
                        </td>
                        <td>{{ props.row.RepeatPatientInfo.Age }}</td>
                        <td>{{ props.row.RepeatPatientInfo.Born }}</td>
                        <td>{{ props.row.RepeatPatientInfo.BornAddress }}</td>
                        <td>{{ props.row.RepeatPatientInfo.Telphone }}</td>
                      </tr>
                    </table>
                  </template>
                </el-table-column>
                <el-table-column
                  width="165px"
                  label="患者主索引"
                  prop="PatientInfo.Code"
                >
                </el-table-column>
                <el-table-column label="类别代码" prop="PatientInfo.Category">
                </el-table-column>
                <el-table-column label="号码" prop="PatientInfo.IdCard">
                </el-table-column>
                <el-table-column label="姓名" prop="PatientInfo.Name">
                </el-table-column>
                <el-table-column label="性别代码" prop="PatientInfo.Gender">
                  <template slot-scope="scope">
                    {{
                      scope.row.PatientInfo.Gender == 1
                        ? "男"
                        : scope.row.PatientInfo.Gender == 2
                        ? "女"
                        : "未知"
                    }}
                  </template>
                </el-table-column>
                <el-table-column label="年龄" prop="PatientInfo.Age">
                </el-table-column>
                <el-table-column label="出生日期" prop="PatientInfo.Born">
                </el-table-column>
                <el-table-column label="出生地" prop="PatientInfo.BornAddress">
                </el-table-column>
                <el-table-column label="联系电话" prop="PatientInfo.Telphone">
                </el-table-column>
                <el-table-column
                  label="状态"
                  fixed="right"
                  width="170"
                  align="center"
                >
                  <template slot-scope="scope">
                    <!-- <el-button
                      v-if="scope.row.RepeatStatus == 0"
                      size="mini"
                      @click="btn_right_b_yes(scope.row.PatientInfo)"
                      >合并</el-button
                    >
                    <el-button
                      v-if="scope.row.RepeatStatus == 0"
                      size="mini"
                      @click="btn_right_b_no(scope.row.PatientInfo)"
                      >忽略</el-button
                    > -->
                    <span v-if="scope.row.RepeatStatus == 0">待清洗</span>
                    <span v-if="scope.row.RepeatStatus == 1">已合并</span>
                  </template>
                </el-table-column>
              </el-table>
              <div class="block" style="text-align: center">
                <el-pagination
                  layout="prev, pager, next"
                  :total="page_right_b.total"
                  :page-size="page_right_b.limit"
                  @current-change="right_b_pag_change"
                  :current-page="page_right_b.page"
                >
                </el-pagination>
              </div>
            </el-col>
          </el-row>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      tableData_right_a: [],
      tableData_right_b: [],
      expands_right_a: [],
      activeName_right_a: "first",
      expands_right_b: [],
      activeName_right_b: "first",
      page_right_a: {
        total: 1,
        page: 1,
        limit: 20,
      },
      page_right_b: {
        total: 1,
        page: 1,
        limit: 20,
      },
      right_table_loading: false,
      code: "",
    };
  },
  methods: {
    getTableData_right_a() {
      this.right_table_loading = true;
      this.$post(
        "/Patient/MergePageList?code=" +
          this.code +
          "&page=" +
          this.page_right_a.page +
          "&limit=" +
          this.page_right_a.limit
      ).then((res) => {
        if (res.code == 0) {
          if (res.data.list == null) {
            this.tableData_right_a = [];
            this.right_table_loading = false;
            return;
          }
          this.tableData_right_a = res.data.list;
          this.page_right_a.total = res.data.TotalCount;
          this.right_table_loading = false;
        } else if (res.code == -1) {
          this.$message.error(res.msg);
          this.right_table_loading = false;
        }
      });
    },
    getTableData_right_b() {
      this.right_table_loading = true;
      this.$post(
        "/Patient/RepeatList?code=" +
          this.code +
          "&page=" +
          this.page_right_b.page +
          "&limit=" +
          this.page_right_b.limit
      ).then((res) => {
        if (res.code == 0) {
          if (res.data.list == null) {
            this.tableData_right_b = [];
            this.right_table_loading = false;
            return;
          }
          this.tableData_right_b = res.data.list;
          this.page_right_b.total = res.data.TotalCount;
          this.right_table_loading = false;
        } else if (res.code == -1) {
          this.$message.error(res.msg);
          this.right_table_loading = false;
        }
      });
    },
    getRowKeys_right_a: function (row) {
      return row.Code;
    },
    expandSelect_right_a: function (row, expandedRows) {
      var that = this;
      if (expandedRows.length) {
        that.expands_right_a = [];
        if (row) {
          that.expands_right_a.push(row.Code);
          this.activeName_right_a = "first";
        }
      } else {
        that.expands_right_a = [];
      }
    },
    getRowKeys_right_b: function (row) {
      return row.PatientInfo.Code;
    },
    expandSelect_right_b: function (row, expandedRows) {
      var that = this;
      if (expandedRows.length) {
        that.expands_right_b = [];
        if (row) {
          that.expands_right_b.push(row.PatientInfo.Code);
          this.activeName_right_b = "first";
        }
      } else {
        that.expands_right_b = [];
      }
    },
    right_a_pag_change(val) {
      this.page_right_a.page = val;
      this.getTableData_right_a();
    },
    right_b_pag_change(val) {
      this.page_right_b.page = val;
      this.getTableData_right_b();
    },
    btn_right_b_yes(val) {
      this.right_table_loading = true;
      let id = val.Id;
      this.$post("/Patient/DealRepeat?repeatCode=" + id + "&dealType=1").then(
        (res) => {
          if (res.code == 0) {
            this.getTableData_right_a();
            this.getTableData_right_b();
            this.$message({
              message: "合并成功",
              type: "success",
            });
          } else if (res.code == -1) {
            this.right_table_loading = false;
            this.$message.error(res.msg);
          }
        }
      );
    },
    btn_right_b_no(val) {
      this.right_table_loading = true;
      let id = val.Id;
      this.$post("/Patient/DealRepeat?repeatCode=" + id + "&dealType=2").then(
        (res) => {
          if (res.code == 0) {
            this.$message({
              message: "忽略成功",
              type: "success",
            });
            this.getTableData_right_a();
            this.getTableData_right_b();
          } else if (res.code == -1) {
            this.right_table_loading = false;
            this.$message.error(res.msg);
          }
        }
      );
    },
  },
  mounted() {
    // document.getElementById("2").focus();
    // this.getTableData_right_a()
    this.getTableData_right_b();
  },
  created() {
    this.msg = this.$route.query;
    console.log(
      "接收过来的传参#############################################################################"
    );
    console.log(this.msg);
    if (this.msg.Token != null && this.msg.Token != "") {
      console.log("设置Token");
      this.$setToken(this.msg.Token);
    } else {
      console.log("Token为空");
    }
  },
};
</script>
<style lang="scss">
.EMPIAdministration_XSSJ {
  .top-input {
    display: inline-block;
    width: 350px;
  }

  .box-top {
    margin-top: 15px;
    margin-left: 5px;
  }
}
.table_style {
  td,
  th {
    padding: 5px 10px !important;
  }
}
</style>

